<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>动态添加显示时间的文本框</title>
  <style>
    button {
      padding: 10px 20px;
      font-size: 16px;
    }
  </style>
</head>

<body>
  <button onclick="addTimeInput()">添加显示时间的文本框</button>
  <script>
    function addTimeInput() {
      const now = new Date();
      const year = now.getFullYear();
      const month = String(now.getMonth() + 1).padStart(2, '0');
      const day = String(now.getDate()).padStart(2, '0');
      const hour = String(now.getHours()).padStart(2, '0');
      const minute = String(now.getMinutes()).padStart(2, '0');
      const second = String(now.getSeconds()).padStart(2, '0');
      const formattedTime = `${year}-${month}-${day} ${hour}:${minute}:${second}`;

      const input = document.createElement('input');
      input.type = 'text';
      input.value = formattedTime;
      document.body.appendChild(input);
    }
  </script>
</body>

</html>